package org.budo.portal.android

/**
 * BudoApiSdk
 */
interface BudoApiSdk {
    fun setCallback(success: Success<Any>, fail: Fail);
<#list interfaces?sort_by("name") as interface>

    fun ${interface.name}(): ${interface.name};
</#list>
}
<#list interfaces?sort_by("name") as interface>

interface ${interface.name} {
    <#list interface.methods?sort_by("name") as method>
        fun ${method.name}(<@compress single_line=true>
            <#list method.parameterNames as parameterName>
                ${method.parameterNames[parameterName_index]} : ${method.parameterTypes[parameterName_index]} <#if parameterName_index lt (method.parameterNames?size-1)>,</#if>
            </#list>
        </@compress>) : Deferred<${method.returnType}>;
    </#list>
}
</#list>

interface Deferred<T> {
    fun then(success: Success<T>, fail: Fail);

    fun then(success: Success<T>);

    fun then();
}

interface Success<T> {
    fun onSuccess(result: T);
}

interface Fail {
    fun onFail(error: Error);
}

interface Error

data class User(
        val id: Int,
        val username: String,
        val password: String
)